<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  User: zoud
  Date: 2017/11/6
  Time: 15:20
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Database Commons - Users</title>
</head>
<body>
<c:if test="${message != null}">
    <div class="ui message">
            ${message}
    </div>
</c:if>
<h3>Users</h3>
<table class="ui celled small table">
    <thead>
    <tr>
        <th>Email</th>
        <th>Full name</th>
        <th>Institution</th>
        <th>Role</th>
        <th>Last curation</th>
        <th>Curated times</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${users}" var="user">
        <tr>
            <td>${user.email}</td>
            <td>${user.fullName}</td>
            <td>${user.organization.name}</td>
            <td>${user.roleList.get(0).name}</td>
            <c:choose>
                <c:when test="${fn:length(user.curationList) > 0}">
                    <td><fmt:formatDate value="${user.curationList.get(0).curationDate}" pattern="yyyy-MM-dd"/></td>
                    <td><a href="${host}/admin/user/curated/database/${user.id}"
                           class="ui mini button primary" style="padding: 5px 10px 5px 10px">${fn:length(user.curationList)}</a></td>
                </c:when>
                <c:otherwise>
                    <td>No curation record.</td>
                    <td>0</td>
                </c:otherwise>
            </c:choose>

        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
</html>
